#include <iostream>
#include <cstring>
#include <unistd.h>
#include <pthread.h>
using namespace std;

void* start_routine(void* arg)
{
    cout << "start_routine: 线程创建成功" << endl;
    for(int i = 0; i < 5; i++)
    {
        cout << "计数----->" << i << endl;
        sleep(1);
    }
    return (void*)10;
}

int main()
{
    pthread_t tid;
    int n = pthread_create(&tid, nullptr, start_routine, nullptr);
    if(n != 0)
    {
        cout << "线程创建失败: " << strerror(n) << endl;
    }
    int result;
    int m = pthread_join(tid, (void**)&result);
    if(m != 0)
    {
        cout << "线程等待失败: " << strerror(m) << endl; 
    }
    cout << "线程的返回值为: " << result << endl;
    return 0;
}